﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace SindSaude
{
    public partial class lateralNoticia : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.carregaNoticias();
        }
        private void carregaNoticias()
        {
            SindSaudeCamadas.Dados.Noticias ultimas_noticias = new SindSaudeCamadas.Dados.Noticias();
            DataTable dt = new DataTable();
            dt = ultimas_noticias.carregaNoticiasCaixa();
            if (dt.Rows.Count > 1)
            {
                GridUltimasNoticias.DataSource = dt;
                GridUltimasNoticias.DataBind();
                GridUltimasNoticias.GridLines = GridLines.None;

            }
        }

        protected void GridUltimasNoticias_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "vermais")
            {
                int idUltimaNoticia = Convert.ToInt16(e.CommandArgument);
                if (idUltimaNoticia != 0)
                {
                    string url = "NoticiasCompleto.aspx?a=" + Convert.ToString(idUltimaNoticia);
                    Response.Write("<script type='text/javascript'>window.open('" + url + "','_parent');</script>");
                }
            }
        }
        
    }
}